AM_CPPFLAGS = \
	-I$(top_srcdir) \
	-DDATADIR=\"$(datadir)\" \
	-DHELPDIR=\"$(docdir)\" \
	-DG_LOG_DOMAIN=\"xfce4-terminal\" \
	-DPACKAGE_LOCALE_DIR=\"$(localedir)\" \
	$(PLATFORM_CPPFLAGS)

bin_PROGRAMS = \
	xfce4-terminal

xfce4_terminal_built_sources = \
	terminal-enum-types.c \
	terminal-enum-types.h \
	terminal-marshal.c \
	terminal-marshal.h

xfce4_terminal_headers = \
	terminal-app.h \
	terminal-encoding-action.h \
	terminal-gdbus.h \
	terminal-image-loader.h \
	terminal-options.h \
	terminal-preferences.h \
	terminal-preferences-dialog.h \
	terminal-private.h \
	terminal-regex.h \
	terminal-search-dialog.h \
	terminal-screen.h \
	terminal-util.h \
	terminal-widget.h \
	terminal-window.h \
	terminal-window-dropdown.h

xfce4_terminal_SOURCES = \
	$(xfce4_terminal_built_sources) \
	$(xfce4_terminal_headers) \
	main.c \
	terminal-app.c \
	terminal-encoding-action.c \
	terminal-gdbus.c \
	terminal-image-loader.c \
	terminal-options.c \
	terminal-preferences.c \
	terminal-preferences-dialog.c \
	terminal-search-dialog.c \
	terminal-screen.c \
	terminal-util.c \
	terminal-widget.c \
	terminal-window.c \
	terminal-window-dropdown.c

xfce4_terminal_CFLAGS = \
	$(GTK_CFLAGS) \
	$(GIO_CFLAGS) \
	$(LIBX11_CFLAGS) \
	$(GTK_LAYER_SHELL_CFLAGS) \
	$(VTE_CFLAGS) \
	$(LIBXFCE4UI_CFLAGS) \
	$(LIBXFCE4KBD_PRIVATE_CFLAGS) \
	$(XFCONF_CFLAGS) \
	$(PCRE2_CFLAGS) \
	$(PLATFORM_CFLAGS)

xfce4_terminal_LDFLAGS = \
	-no-undefined \
	$(LIBX11_LDFLAGS) \
	$(PLATFORM_LDFLAGS)

xfce4_terminal_LDADD = \
	$(GTK_LIBS) \
	$(GIO_LIBS) \
	$(LIBX11_LIBS) \
	$(GTK_LAYER_SHELL_LIBS) \
	$(VTE_LIBS) \
	$(LIBXFCE4UI_LIBS) \
	$(LIBXFCE4KBD_PRIVATE_LIBS) \
	$(XFCONF_LIBS) \
	$(PCRE2_LIBS)

if HAVE_UTEMPTER
xfce4_terminal_LDADD += -lutempter
endif

if FREEBSD
xfce4_terminal_LDADD += -lprocstat -lutil
endif

##
## Rules to auto-generate built sources
##
## This is a bit tricky with automake, and non-trivial to implement. The
## rules below seem to work fine and don't seem to break the build, but
## they are only enabled in maintainer mode, so arbitrary users don't get
## trapped in automake's oddities. Therefore we ship the autogenerated
## files as part of the dist tarball.
##
if MAINTAINER_MODE
CLEANFILES = \
	xgen-tetc \
	xgen-teth \
	xgen-tmc \
	xgen-tmh

DISTCLEANFILES = \
	$(xfce4_terminal_built_sources) \
	stamp-terminal-enum-types.h \
	stamp-terminal-marshal.h

BUILT_SOURCES = \
	$(xfce4_terminal_built_sources)

terminal-enum-types.h: stamp-terminal-enum-types.h
	@true
stamp-terminal-enum-types.h: terminal-preferences.h Makefile
	$(AM_V_GEN)  ( cd $(srcdir) && glib-mkenums \
	--fhead "#ifndef TERMINAL_ENUM_TYPES_H\n#define TERMINAL_ENUM_TYPES_H\n#include <gtk/gtk.h>\nG_BEGIN_DECLS\n" \
	--fprod "/* enumerations from \"@filename@\" */\n" \
	--vhead "GType @enum_name@_get_type (void);\n#define TERMINAL_TYPE_@ENUMSHORT@ (@enum_name@_get_type())\n" \
	--ftail "G_END_DECLS\n\n#endif /* !TERMINAL_ENUM_TYPES_H */" \
	terminal-preferences.h ) >> xgen-teth \
	&& (cmp -s xgen-teth terminal-enum-types.h || cp xgen-teth terminal-enum-types.h ) \
	&& rm -f xgen-teth \
	&& echo timestamp > $(@F)

terminal-enum-types.c: terminal-preferences.h Makefile
	$(AM_V_GEN) ( cd $(srcdir) && glib-mkenums \
	--fhead "#ifdef HAVE_CONFIG_H\n#include <config.h>\n#endif\n#undef GTK_DISABLE_DEPRECATED\n#define GTK_ENABLE_BROKEN\n#include <terminal/terminal-enum-types.h>\n#include <terminal/terminal-app.h>\n#include <terminal/terminal-preferences.h>" \
	--fprod " \n/* enumerations from \"@filename@\" */" \
	--vhead "GType\n@enum_name@_get_type (void)\n{\n\tstatic GType type = 0;\n\tif (type == 0) {\n\tstatic const G@Type@Value values[] = {" \
	--vprod " \t{ @VALUENAME@, \"@VALUENAME@\", \"@valuenick@\" }," \
	--vtail " \t{ 0, NULL, NULL }\n\t};\n\ttype = g_@type@_register_static (\"@EnumName@\", values);\n  }\n\treturn type;\n}\n" \
	terminal-preferences.h ) >> xgen-tetc \
	&& cp xgen-tetc terminal-enum-types.c \
	&& rm -f xgen-tetc

terminal-marshal.h: stamp-terminal-marshal.h
	@true
stamp-terminal-marshal.h: terminal-marshal.list Makefile
	$(AM_V_GEN) ( cd $(srcdir) && glib-genmarshal \
	--prefix=_terminal_marshal \
	--header terminal-marshal.list ) >> xgen-tmh \
	&& ( cmp -s xgen-tmh terminal-marshal.h || cp xgen-tmh terminal-marshal.h ) \
	&& rm -f xgen-tmh \
	&& echo timestamp > $(@F)

terminal-marshal.c: terminal-marshal.list Makefile
	$(AM_V_GEN) echo "#include <terminal/terminal-marshal.h>" > xgen-tmc \
	&& ( cd $(srcdir) && glib-genmarshal \
	--prefix=_terminal_marshal \
	--body terminal-marshal.list ) >> xgen-tmc \
	&& cp xgen-tmc terminal-marshal.c \
	&& rm -f xgen-tmc
endif


clean-local:
	rm -f *.core core core.*

EXTRA_DIST = \
	terminal-config.h.in \
	terminal-marshal.list

# vi:set ts=8 sw=8 noet ai nocindent:
